#pragma once

#include "stdafx.h"
#include "dbg_log_output.h"
#include "FFMediaSource.h"

class FFByteStreamHandler : 
	public IMFByteStreamHandler,
	public IMFAsyncCallback
{
	ULONG RefCount = 1;
	IMFAsyncResult* pAsyncResult = NULL;
	FFMediaSource* pFFMediaSource = NULL;
	WCHAR szFileName[MAX_PATH];
public:
	FFByteStreamHandler() = default;
	~FFByteStreamHandler()
	{
		SAFE_RELEASE(pAsyncResult);
		SAFE_RELEASE(pFFMediaSource);
	}
public:
	IFACEMETHODIMP QueryInterface(REFIID riid,void** ppv);
	IFACEMETHODIMP_(ULONG) AddRef();
	IFACEMETHODIMP_(ULONG) Release();
public:
	STDMETHODIMP BeginCreateObject(IMFByteStream* pByteStream,LPCWSTR pwszURL,DWORD dwFlags,IPropertyStore* pProps,IUnknown** ppIUnknownCancelCookie,IMFAsyncCallback* pCallback,IUnknown* punkState);
	STDMETHODIMP EndCreateObject(IMFAsyncResult* pResult,MF_OBJECT_TYPE* pObjectType,IUnknown** ppObject);
	STDMETHODIMP CancelObjectCreation(IUnknown* pIUnknownCancelCookie) {return E_NOTIMPL;}
	STDMETHODIMP GetMaxNumberOfBytesRequiredForResolution(QWORD* pqwBytes) {return E_NOTIMPL;}
public:
	STDMETHODIMP GetParameters(DWORD* pdwFlags,DWORD* pdwQueue) {return E_NOTIMPL;}
	STDMETHODIMP Invoke(IMFAsyncResult* pResult);
};